package edu.hue.jk.controller;

import edu.hue.jk.Mapper.RoomDao;
import edu.hue.jk.entity.Room;

import edu.hue.jk.entity.Student;
import edu.hue.jk.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Room)表控制层
 *
 * @author makejava
 * @since 2022-03-16 15:46:59
 */
@Controller
@RequestMapping("user/room")
public class RoomController {

    @Autowired
    private RoomService roomService;

    //跳转宿舍查询页面
    @RequestMapping("selectroom")
    public String selectroom(){
        return "selectroom_1";
    }

    //根据查询条件显示查询结果
    @RequestMapping("selectroom_1")
    public String selectroom_1(int did, Model model){
        return roomService.selectroom_1(did,model);
    }
    //跳转学生信息列表
    @RequestMapping("list")
    public String list(Model model){
        return roomService.list(model);
    }

    //添加学生信息页面
    @RequestMapping("add")
    public String add(){
        return roomService.add();
    }
    //更新学生信息
    @RequestMapping("update")
    public String update(Student student, Model model){
        return roomService.update(student,model);
    }

    //将存在学生信息展示在修改页面
    @RequestMapping("update_1")
    public String update(String sid,Model model) {
        return roomService.updates(sid, model);
    }

    //删除相应学生信息
    @RequestMapping("delete")
    public String delete(Model model,String sid){
        return roomService.delete(model, sid);
    }

    @RequestMapping("query")
    public String query(){
        return "querystudent_1";
    }
}